package com.stx.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.stx.dao.FactoryDao;
import com.stx.entity.Factory;

/**
 * Servlet implementation class showfactory
 */
public class showfactory extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public showfactory() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		FactoryDao factorydao=new FactoryDao();
		//factorydao.showFactory();
		List<Factory> factorylist =new ArrayList<Factory>();
		factorylist=factorydao.showFactory();
		for(Factory f : factorylist){
			System.out.println(f.getMfactoryaddress());
		}
		//String s= "hahahahhh";
		request.setAttribute("factorylist", factorylist);
		//request.setAttribute("1", s);
		request.getRequestDispatcher("/admin/factory.jsp").forward(request, response);
	}

}
